<template>
  <!-- 修改场所信息 -->
  <view class="revampSiteInfo">
    <view class="revampSiteInfo-wrapper">
      <view class="revampSiteInfo-content revampSiteInfo-card">
        <view v-for="item in menuList" :key="item.id">
          <view v-if="item.flag" class="person-con"
            :data-url="`${item.url}?id=${options.id}&orFlag=2&lvguan=${options.industryInformationId_dictText}`"
            @click="personHandle($event, item)">
            <view>
              {{ item.name }}
            </view>
            <view>
              <u-icon name="arrow-right" style="color: #9e9e9e"></u-icon>
            </view>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
  import {
    messageDetail
  } from "@/api/myself.js";

  export default {
    name: "revampSiteInfo",
    data() {
      return {
        baseImgUrl: this.$baseImgUrl,
        options: {},
        num: 0,
        role: uni.getStorageSync('role')
      };
    },
    computed: {
      menuList() {
        let menuArr = [{
            id: 1,
            name: "基本信息",
            url: "/selfInfo/revampPlaceInfo/placeBasic",
            flag: true,
          },
          {
            id: 2,
            name: "资质信息",
            url: "/selfInfo/revampPlaceInfo/placeAptitude",
            flag: true,
          },
          {
            id: 3,
            name: "法人/经营者信息",
            url: "/selfInfo/revampPlaceInfo/placeLegalPerson",
            flag: true,
          },
          {
            id: 4,
            name: "负责人信息",
            url: "/selfInfo/revampPlaceInfo/placeSafetyxdirector",
            flag: true,
          },
        ]
        if (['mini'].includes(this.role)) {
          console.log('包含mini')
          return menuArr.filter(item => item.name !== '负责人信息')
        } else {
          return menuArr
        }
      }
    },
    onLoad(options) {
      this.options = JSON.parse(decodeURIComponent(options.data));

      // if (this.options.industryInformationId_dictText != "旅馆业")
      //   return (this.menuList[1].flag = false);
    },
    methods: {
      personHandle(e, item) {
        let url = e.currentTarget.dataset.url;

        if (item.id == 4) {
          messageDetail({
            companyId: this.options.id
          }).then((res) => {
            if (res.code == 200) {
              if (res.result.dutyPersonInfo) {
                uni.navigateTo({
                  url,
                });
              } else {
                uni.navigateTo({
                  url: `/selfInfo/revampPlaceInfo/placeSafetyxdirectorOld?id=${this.options.id}`,
                });
              }
            }
          });

          return;
        }

        uni.navigateTo({
          url,
        });
      },
    },
  };
</script>

<style lang="scss" scoped>
  .revampSiteInfo {
    display: flex;
    flex-direction: column;
    position: relative;
    width: 100%;
    height: 100%;
    background: #f9f9f9;

    .revampSiteInfo-wrapper {
      margin-top: 20rpx;

      .revampSiteInfo-content {
        margin: 0 auto;
        padding: 2vh 3vh 0;
        width: 710rpx;
      }

      .revampSiteInfo-card {
        height: calc(100vh - 20px);
        border-radius: 16rpx;
        background: #fff;
        font-size: 30rpx;

        .person-con {
          display: flex;
          justify-content: space-between;
          align-items: center;
          padding: 1.7vh 0;
          border-bottom: 1px solid #f3f3f3;
          font-weight: 500;

          .u-iconfont {
            margin-right: 1vh;
          }
        }
      }
    }
  }
</style>